package com.lineng.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.alibaba.fastjson.JSON;
import com.lineng.pojo.Generalize;
import com.lineng.service.GeneralizeService;

@Controller
public class GeneralizaController {

	@Autowired
	GeneralizeService generalizeService;

	/**
	 * 获取书院概括内容
	 * 
	 * @return
	 */
	@RequestMapping(value = "/getGeneraliza", method = RequestMethod.GET, produces = "text/json;charset=UTF-8")
	@ResponseBody
	public String getGeneraliza(HttpServletRequest request) {
		return JSON.toJSONString(generalizeService.getGeneralize());

	}

	/**
	 * 更改书院概括内容
	 * 
	 * @param generalize
	 * @param file
	 * @return
	 */
	@RequestMapping(value = "/updateGeneraliza", method = RequestMethod.POST, produces = "text/json;charset=UTF-8")
	@ResponseBody
	public String updateGeneraliza(Generalize generalize, MultipartFile file, HttpServletRequest request) {
		String username = (String) request.getSession().getAttribute("username");
		return JSON.toJSONString(generalizeService.updateGeneraliza(generalize, file, username));

	}
}
